﻿using Stardust.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace WebNode1_2
{
    public class User
    {
        public int ID { get; set; }

        public string Name { get; set; }
        public string Msg { get; set; }
    }
    public class UserService : IStardustService
    {
        public User GetOne(int id = 0)
        {
            User u = new User();
            u.ID = id;
            u.Name = "姓名：" + id.ToString();
            u.Msg = "From ndoe1-2";
            return u;
        }

        public List<User> GetUsers(int count = 1)
        {
            List<User> list = new List<WebNode1_2.User>();
            for (int i = 0; i < count; i++)
            {
                list.Add(new User
                {
                    ID = i,
                    Msg = "msg" + (i + 10),
                    Name = "name" + (i + 10)
                });
            }
            return list;

        }


        public Task<User> GetOne1(int id = 0)
        {
            return new Task<User>(() =>
            {
                return new User
                {
                    ID = 23,
                    Msg = "ndoe-1-2",
                    Name = "sdfsdf"
                };
            });
        }

        public string Say(string name)
        {
            return "Hello," + name + "!  --from:" + StardustServer.UniqueNodeName;
        }
    }
}